<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>clock.html</title>
<script>
	window.onload = function() {
		var start = document.getElementById("btnStart");
		var stop = document.getElementById("btnStop");

		start.onclick = function() {
			obj = setInterval(setClock, 1000);//스레드 시작

		}
		stop.onclick = function() {
			clearInterval(obj);//스레드 중지
		}

	}
	function setClock() {
		var y = document.getElementById("ymd");
		var time= document.getElementById("hms");
		
		var now= new Date();
		y.value = now.getFullYear()+" 년";
		y.value += (now.getMonth()+1)+" 월";
		y.value += (now.getDate())+" 일";
		
		time.value=now.getHours() +"시";
		time.value+=now.getMinutes()+"분";
		time.value+=now.getSeconds()+"초";
		
		window.status=time.value;
	}
</script>
</head>
<body>
	<input type='text' id='ymd' readonly>
	<br />
	<input type='text' id='hms' readonly>
	<p />
	<input type='button' value='시작' id='btnStart'>
	<input type='button' value='종료' id='btnStop'>

</body>
</html>